<!DOCTYPE html>
<html lang="en">
<head>
    <#import "../common/common.macro.ftl" as netCommon>
	<@netCommon.commonStyle />
</head>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">
    <!-- header -->
	<@netCommon.commonHeader />
    <!-- left -->
	<@netCommon.commonLeft "app" "appPower" />

    <div class="content-wrapper">
        <!-- Content Header (Page header) -->
        <section class="content-header">
            <!-- SELECT2 EXAMPLE -->
            <div class="box box-default">
                <!-- /.box-header -->
                <div class="box-body">
                    <form id="appUser" action="${request.contextPath}/app/selectAppPower" method="post" onsubmit="return ckeckAppLeader();">
                        <div class="row col-sm-offset-1">
                            <div class="col-md-5">
                                <div class="form-group">
                                    <label>选择应用</label>
                                    <select id="appId" name="appId" class="form-control select2"
                                            data-placeholder="Select a State" style="width: 100%;">
                                        <option value="">请选择应用....</option>
                                        <#if appList?exists >
                                            <#list appList as item>
                                                <option <#if appId?exists && appId == item.appId >selected</#if>
                                                        value="${item.appId}">${item.appId}</option>
                                            </#list>
                                        </#if>
                                    </select>
                                </div>
                                <!-- /.form-group -->
                            </div>
                            <div class="col-sm-1">
                                <label></label>
                                <button type="submit" class="btn btn-block btn-primary">查询</button>
                            </div>
                            <!-- /.col -->
                        </div>
                    </form>
                </div>
                <!-- /.box-body -->
            </div>
            <!-- /.box -->
        </section>

        <!-- Main content -->
        <#if resourcesList?exists >
        <section class="content">
            <div class="row">
                <div class="col-xs-12">
                    <div class="box">
                        <div class="box-header">
                            <div class="col-sm-2">
                                <button id="toAddResources" type="button" class="btn btn-block btn-primary">新增资源</button>
                            </div>
                            <div class="col-sm-2">
                                <button id="refreshRedis" type="button" class="btn btn-block btn-warning">刷新缓存</button>
                            </div>
                        </div>
                        <!-- /.box-header -->
                        <div class="box-body">
                            <table id="dataList" style="width:100%" class="table table-bordered table-hover">
                                <thead>
                                <tr>
                                    <th>资源名称</th>
                                    <th>资源路径</th>
                                    <th>资源描述</th>
                                    <th>是否登录</th>
                                    <th>创建时间</th>
                                    <th>更新时间</th>
                                    <th>操作</th>
                                </tr>
                                </thead>
                                <tbody>
                                    <#list resourcesList as item>
                                    <tr id="${item.id}">
                                        <td>${item.resName!''}</td>
                                        <td>${item.resPath!''}</td>
                                        <td>${item.resDesc!''}</td>
                                        <td>
                                            <#if item.login == "true">是</#if>
                                            <#if item.login == "false">否</#if>
                                        </td>
                                        <td>${item.createTime?string('yyyy-MM-dd HH:mm:ss')}</td>
                                        <td>${item.updateTime?string('yyyy-MM-dd HH:mm:ss')}</td>
                                        <td>
                                            <div class="col-md-4">
                                                <button type="button" class="btn btn-block btn-warning btn-xs" onclick="toUpdateRes('${item.appId}','${item.id}')">编辑</button>
                                            </div>
                                            <div class="col-md-4">
                                                <button onclick="toAddResourcesRole('${item.id}')" type="button" class="btn btn-block btn-primary btn-xs">权限</button>
                                            </div>
                                            <div class="col-md-4">
                                                <button type="button" class="btn btn-block btn-danger btn-xs" onclick="deleteRes('${item.id}')">删除</button>
                                            </div>
                                        </td>
                                    </tr>
                                    </#list>
                                </tbody>
                            </table>
                        </div>
                        <!-- /.box-body -->
                    </div>
                    <!-- /.box -->
                </div>
            </div>
        </section>
        </#if>
    </div>
</div>

<@netCommon.commonScript />
<script src="${request.contextPath}/static/js/app.js"></script>
</body>
</html>